package com.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dao.chuangweiguanliDao;
import com.entity.chuangweiguanliEntity;
import com.entity.view.chuangweiguanliView;
import com.entity.vo.chuangweiguanliVO;
import com.service.chuangweiguanliService;
import com.utils.PageUtils;
import com.utils.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("chuangweiguanliService")
public class chuangweiguanliServiceImpl extends ServiceImpl<chuangweiguanliDao, chuangweiguanliEntity> implements chuangweiguanliService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<chuangweiguanliEntity> page = this.selectPage(
                new Query<chuangweiguanliEntity>(params).getPage(),
                new EntityWrapper<chuangweiguanliEntity>()
        );
        return new PageUtils(page);
    }

    @Override
	public PageUtils queryPage(Map<String, Object> params, Wrapper<chuangweiguanliEntity> wrapper) {
		  Page<chuangweiguanliView> page =new Query<chuangweiguanliView>(params).getPage();
	        page.setRecords(baseMapper.selectListView(page,wrapper));
	    	PageUtils pageUtil = new PageUtils(page);
	    	return pageUtil;
 	}

    @Override
	public List<chuangweiguanliVO> selectListVO(Wrapper<chuangweiguanliEntity> wrapper) {
 		return baseMapper.selectListVO(wrapper);
	}

	@Override
	public chuangweiguanliVO selectVO(Wrapper<chuangweiguanliEntity> wrapper) {
 		return baseMapper.selectVO(wrapper);
	}

	@Override
	public List<chuangweiguanliView> selectListView(Wrapper<chuangweiguanliEntity> wrapper) {
		return baseMapper.selectListView(wrapper);
	}

	@Override
	public chuangweiguanliView selectView(Wrapper<chuangweiguanliEntity> wrapper) {
		return baseMapper.selectView(wrapper);
	}
	@Override
	public void deleteByChuangweihao(String chuangweihao, Wrapper<chuangweiguanliEntity> wrapper) {
		wrapper.eq("chuangweihao", chuangweihao);
		this.baseMapper.delete(wrapper);
	}
}
